package api

import (
	"github.com/gin-gonic/gin"
	"rbook/api/handler"
	"rbook/api/middwhere"
	"rbook/consts"
	"rbook/pkg"
)

func LoadRouter(c *gin.Engine) {
	c.Use(middwhere.JWT_Auth())
	c.Use(handler.Cross())
	api := c.Group("/api")
	{
		user := api.Group("/user")
		{
			user.POST("/sendSms", handler.SendSms)
			user.POST("/login", handler.Login)
			//每日凌晨自动汇总当日登录用户数
			user.POST("/time", handler.Time)
			user.Use(pkg.GetToken(consts.JWT_KEY))
			user.POST("/details", handler.UserDetails)
		}
		content := api.Group("/content")
		{
			content.POST("/list", handler.ContentList)
			content.POST("/details", handler.ContentDetails)
		}
		chant := api.Group("/chant")
		{
			chant.GET("/send", handler.Chant)
		}
		comment := api.Group("/comment")
		{
			comment.POST("/add", handler.CommentAdd)
			comment.POST("/update", handler.CommentUpdate)
		}
		message := api.Group("/message")
		{
			message.POST("/message", handler.MessageList)
			message.POST("/time", handler.TimeAgo)
		}
		search := api.Group("/search")
		{
			search.POST("/search", handler.SearchShow)
			search.POST("/time", handler.SearchTime)
		}
	}
}
